var api = require('../../utils/api.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },


  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    var tamecodes=wx.getStorageSync('tamecodes');

    if(!tamecodes){

        wx.switchTab({
          url: '/pages/index/index',
        })
    }


    this.getmytameorder();
  },

  getmytameorder(){
    var that=this;
    that.setData({
        list:[]
      })
    api.get({
        url: 'wxapp/user/getmytameorder',
        data: {},
        success: data => {
            var list=data.data;
            that.setData({
              list:list
            })
  
        }
    });

  },

  delete(ret){

    console.log(ret);
    var that=this;
    var id=ret.currentTarget.dataset.id;

    wx.showModal({
      title: '删除订单',
      content: '确认要删除订单吗?',
      complete: (res) => {
        if (res.confirm) {
            
            api.get({
                url: 'wxapp/user/deletetameorder',
                data: {id:id},
                success: data => {
         
                    that.getmytameorder();

          
                }
            });

            

        }
      }
    })

  },

  addorder(){

    wx.navigateTo({
      url: '/pages/my/addtame',
    })
  }

})